package com.views
{
	import com.View;
	import com.ViewBase;
	import com.views.structure.Alert;
	import com.views.structure.Background;
	import com.views.structure.Content;
	import com.views.structure.Load;
	import com.views.structure.Popup;
	import com.views.structure.Tip;
	
	import flash.display.Sprite;
	import flash.display.Stage;
	
	import mx.core.Singleton;

	public class Structure
	{
		public static const minStageWidth :uint = 1000;
		public static const minStageHeight :uint = 600;
		public static const maxStageWidth :uint = 1250;
		public static const maxStageHeight :uint = 650;
		
		private var _stage :Stage;
		private var _view :View;
		
		private var _mouse :Sprite;
		private var _tip :Tip;
		private var _alert :Alert;
		private var _load :Load;
		private var _content :Content;
		private var _background :Background;
		private var _popup :Popup;
		
		private static var _instance :Structure;
		
		public function Structure( singleton :Singleton )
		{
		}
		
		public function init( stage :Stage, view :View ) :void {
			_stage = stage;
			_view = view;
			
			_mouse = new Sprite();
			_tip = new Tip();
			_alert = new Alert();
			_load = new Load();
			_content = new Content();
			_background = new Background();
			_popup = new Popup( _view );
			
			_stage.addChild( _background );
			_stage.addChild( _content );
			_stage.addChild( _popup );
			_stage.addChild( _alert );
			_stage.addChild( _load );
			_stage.addChild( _tip );
			_stage.addChild( _mouse );
			
			_popup.structure = this;
			_popup.mouseEnabled = false;
			_popup.tabEnabled = false;
			_popup.tabChildren = false;
			
			_mouse.mouseEnabled = false;
			_mouse.mouseChildren = false;
			
			_tip.mouseEnabled = false;
			
			_content.tabEnabled = false;
			_content.tabChildren = false;
		}
		
		public static function getInstance( stage :Stage, viewBase :ViewBase ) :Structure {
			if( _instance == null ) {
				_instance = new Structure( new Singleton() );
				_instance.init( stage, viewBase as View );
			}
			
			return _instance;
		}
		
		public function get popup() : Popup
		{
			return _popup;
		}
	}
}

class Singleton {
	
}